package com.example.fw;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class JdbcHelper extends HelperBase{

	private Connection conn;
	
	public JdbcHelper(ApplicationManager app) {
		super(app);
		try {
			Class.forName("com.mysql.jdbc.Driver").newInstance();
		} catch (Exception e) {
			e.printStackTrace();
		}
		
		try {
			conn = DriverManager.getConnection(manager.getProperty("db.url"));
		} catch (SQLException e) {
			e.printStackTrace();
		}
	}
	
	public void deleteUser(String username){
		Statement st = null;
		ResultSet res = null;
		
		try {
			st = conn.createStatement();
			res = st.executeQuery("DELETE FROM `mantis_user_table` WHERE `username`=\"" + username + "\"");
		} catch (SQLException e) {
			e.printStackTrace();
		} finally {
			try {
				res.close();
				st.close();
			} catch (SQLException e) {
				e.printStackTrace();
			}
		}
		
	}

}
